<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			.aaa{
				color: red;
			}
		</style>
		<script>
			function submit_f(obj){
				var uname = obj.uname.value;
				var email = obj.email.value;
				var e_reg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
				var phone = /^[1][3|5|6|7|8][0-9]{9}$/;
				if(!phone.test(uname))
				{
					alert('请输入合法的电话');
					return false;
				}
				
				if(!e_reg.test(email))
				{
					alert('请输入合法的邮件');
					return false;
				}
			  return true;
			}
			
			function submit_g(obj){
				var uname = obj.uname.value;
				var email = obj.email.value;
				var e_reg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
				var phone = /^[1][3|5|6|7|8][0-9]{9}$/;
				if(!phone.test(uname))
				{
					var span = obj.uname.nextElementSibling;
					span.innerText = '请输入合法的电话';
					return false;
				}
				
				if(!e_reg.test(email))
				{
					var span = obj.email.nextElementSibling;
					span.innerText = '请输入合法的邮件';
					return false;
				}
			  return true;
			}
		</script>
	</head>
	<body>
		<form action="index.html" method="post" onsubmit="return submit_g(this)">
			电话:<input  type="text" name="uname" /><span class="aaa"></span><br/>
			邮    件:<input  type="text" name="email" /><span class="aaa"></span><br/>
			<input type="submit" value="提交"/>
		</form>
	</body>
</html>
